Skip to content

feat(channels): set and read channel icons by name - #171

Merged
scottlovegrove merged 3 commits into
mainfrom
scottl/channel-icon-name
Dec 3, 2026
Merged

scottlovegrove merged 3 commits into
mainfrom
scottl/channel-icon-name

Conversation

@scottlovegrove

@scottlovegrove scottlovegrove commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

The Comms API now stores a channel's icon as a name, sent and returned as icon_name. The old integer icon is ignored on channels/add and channels/update, and always reads back as 0. The SDK only knew about icon, so callers had no way to set or read a channel's icon, and a write to icon silently did nothing.

This adds iconName to Channel, CreateChannelArgs and UpdateChannelArgs. null resets the icon to the default #. CHANNEL_ICON_NAMES lists the 49 names the backend accepts today, and the schemas build iconName from it, so ChannelIconName is the plain union and an unlisted name fails type-check. The backend appends icons over time, so a newer server can return a name this SDK doesn't list yet: Channel.iconName reads one as null, the default icon, rather than failing the parse, which is how the backend asks clients to show an icon they don't know. Callers that validate input (comms-mcp, for its create-channel and update-channel tools) can reuse the list.

The integer icon is marked @deprecated on the entity and both arg types. Those types are inferred from the Zod schemas, and tsc drops property comments from inferred declarations, so the tag documents it in the source but won't strike the field through in consumers' editors.

UpdateChannelArgs.name is now optional. The endpoint already takes a partial update, so changing only the icon or colour no longer needs the current name sent back. This only widens the type, so nothing existing breaks.

The API stores a channel's icon as a name (icon_name) and ignores the
old integer icon: writes to it are dropped and it always reads back 0.
Add iconName to Channel, CreateChannelArgs and UpdateChannelArgs, export
CHANNEL_ICON_NAMES and ChannelIconName as a hint list (the schemas accept
any string, as the backend appends icons over time), and mark the integer
icon as deprecated.

Also make name optional on UpdateChannelArgs: the endpoint takes a
partial update, so changing only the icon or colour no longer needs the
current name sent back.
@scottlovegrove scottlovegrove self-assigned this Dec 3, 2026

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds iconName support to channels end to end — the new CHANNEL_ICON_NAMES/ChannelIconName const-array union, iconName on Channel, CreateChannelArgs and UpdateChannelArgs with null resetting to the default, a deprecated integer icon, and an optional UpdateChannelArgs.name — all proven with tests at the public client interface covering create, partial update, reset, and unlisted icon names. No inline issues were flagged; the change follows the established patterns (schema-permissive unions, transport case conversion, shared fixtures) and no concerns were raised for security or reuse.

I also included a few optional follow-up notes in the details below.

Optional follow-up notes (2)
  • P3 src/clients/channels-client.test.ts:138: This test restates the constant rather than exercising behaviour: toContain('heart')/toContain('apple') duplicate what the array already says, and toHaveLength(49) has to be edited every time the backend appends a name (the reason the schema accepts any string in the first place). The only invariant worth keeping is the duplicate check on line 139. Consider dropping the containment/length assertions, or deleting the test and letting entities.test.ts cover schema parsing.
  • P3 src/clients/channels-client.test.ts:131: expect(CHANNEL_ICON_NAMES).not.toContain('rocket') breaks the day the backend appends rocket, which is exactly the growth this feature exists to absorb — that PR would then have to touch an unrelated test to get green. Use a name that can never be a real icon (e.g. 'icon-from-a-newer-api') so the unlisted-name case keeps testing what it's named for.

Share Feedback • Review Logs • Trace

Use a name that can never be a real icon for the unlisted-name case, and
drop the containment and length checks on CHANNEL_ICON_NAMES, which would
need editing each time the backend appends an icon.
@scottlovegrove scottlovegrove added the 🚢 Ship PR requires passing checks before merge, but no independent human review. label Dec 3, 2026
Build iconName from CHANNEL_ICON_NAMES in the request and Channel
schemas, so an unlisted name fails type-check and ChannelIconName is the
plain union. A name a newer API returns that this SDK doesn't list yet
reads as null, the default icon, rather than failing the parse, which is
how the backend asks clients to show an icon they don't know.
@scottlovegrove
scottlovegrove merged commit 31e2624 into main Dec 3, 2026
6 checks passed
@scottlovegrove
scottlovegrove deleted the scottl/channel-icon-name branch December 3, 2026 12:51
doist-release-bot Bot added a commit that referenced this pull request Dec 3, 2026
## [6.3.0](v6.2.3...v6.3.0) (2026-12-03)

### Features

* **channels:** set and read channel icons by name ([#171](#171)) ([31e2624](31e2624))
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released 🚢 Ship PR requires passing checks before merge, but no independent human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants